import 'package:erp/main_state.dart';
import 'package:erp/res/colors.dart';
import 'package:erp/routes/app_pages.dart';
import 'package:erp/util/image_utils.dart';
import 'package:erp/widgets/load_image.dart';
import 'package:erp/widgets/my_app_bar.dart';
import 'package:erp/widgets/my_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class Mine extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    MainState ms = Get.find<MainState>();

    var right_arrow = LoadAssetImage(
      'mine/right_arrow',
      width: 19.w,
      height: 33.h,
    );

    return Container(
      /// banner
      decoration: BoxDecoration(
        image: DecorationImage(
          alignment: Alignment.topCenter,
          image: ImageUtils.getImageProvider("", holderImg: 'mine/banner'),
          fit: BoxFit.fitWidth,
        ),
      ),
      child: Scaffold(
        backgroundColor: Colors.transparent,
        appBar: MyAppBar(
          isBack: false,
          backgroundColor: Colors.transparent,
          centerTitle: '我的',
        ),
        body: Container(
          width: double.infinity,
          height: double.infinity,
          child: Stack(
            children: <Widget>[
              Container(
                height: 233.h,
                color: Colors.transparent,
                width: double.infinity,
                child: Padding(
                  padding: EdgeInsets.only(left: 70.w),
                  child: Row(
                    children: [
                      ClipOval(
                        child: Image.network(
                          'https://pic2.zhimg.com/v2-639b49f2f6578eabddc458b84eb3c6a1.jpg',
                          width: 140.w,
                          height: 140.w,
                          fit: BoxFit.cover,
                        ),
                      ),
                      SizedBox(width: 40.w),
                      Container(
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: [
                            Container(
                              child: Row(
                                children: [
                                  Text(
                                    "${ms.userInfo.value!.empName}",
                                    style: TextStyle(color: Colors.white, fontSize: 40.sp, fontWeight: FontWeight.w400),
                                  ),
                                  SizedBox(width: 20.w),
                                  Container(
                                    width: 150.w,
                                    height: 42.h,
                                    decoration: BoxDecoration(
                                      color: Colors.white,
                                      borderRadius: BorderRadius.all(Radius.circular(21.r)),
                                    ),
                                    child: Center(
                                      child: Tooltip(
                                        child: Text(
                                          "${ms.userInfo.value!.positionName}",
                                          overflow: TextOverflow.ellipsis,
                                          style: TextStyle(
                                              color: Color(0xff5EABF7), fontSize: 24.sp, fontWeight: FontWeight.w400),
                                        ),
                                        message: "${ms.userInfo.value!.positionName}",
                                      ),
                                    ),
                                  ),
                                ],
                              ),
                            ),
                            SizedBox(height: 30.h),
                            Text(
                              "研发中心 - 软件开发部",
                              style: TextStyle(color: Colors.white, fontSize: 28.sp, fontWeight: FontWeight.w400),
                            ),
                          ],
                        ),
                      ),
                    ],
                  ),
                ),
              ),
              Positioned(
                left: 0,
                right: 0,
                top: 233.h,
                bottom: 0,
                child: Ink(
                  decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.only(topLeft: Radius.circular(40.r), topRight: Radius.circular(40.r)),
                  ),
                  child: Container(
                    height: double.infinity,
                    child: Padding(
                      padding: EdgeInsets.only(top: 40.w),
                      child: Column(
                        children: [
                          InkWell(
                            highlightColor: Colours.bg_color,
                            onTap: () {
                              Get.toNamed(Routes.MY_PROFILE);
                            },
                            child: Container(
                              padding: EdgeInsets.symmetric(horizontal: 70.w),
                              height: 115.h,
                              child: Row(
                                children: [
                                  LoadAssetImage(
                                    'mine/profile',
                                    width: 37.w,
                                    height: 43.h,
                                  ),
                                  SizedBox(width: 31.w),
                                  Text(
                                    "我的资料",
                                    style: TextStyle(
                                      color: Color(0xFF444444),
                                      fontSize: 32.sp,
                                    ),
                                  ),
                                  Expanded(child: Container()),
                                  right_arrow,
                                ],
                              ),
                            ),
                          ),
                          InkWell(
                            highlightColor: Colours.bg_color,
                            onTap: () {
                              Get.toNamed(Routes.PASSWORD);
                            },
                            child: Container(
                              padding: EdgeInsets.symmetric(horizontal: 70.w),
                              height: 115.h,
                              child: Row(
                                children: [
                                  LoadAssetImage(
                                    'mine/setting',
                                    width: 39.w,
                                    height: 38.h,
                                  ),
                                  SizedBox(width: 31.w),
                                  Text(
                                    "修改密码",
                                    style: TextStyle(
                                        color: Color(0xFF444444), fontSize: 32.sp, fontWeight: FontWeight.w400),
                                  ),
                                  Expanded(child: Container()),
                                  right_arrow,
                                ],
                              ),
                            ),
                          ),
                          Expanded(child: Container()),
                          Container(
                            decoration: BoxDecoration(
                              gradient: LinearGradient(
                                colors: [Color(0xFF5FBBFA), Color(0XFF4D8AFE)],
                              ),
                              borderRadius: BorderRadius.circular(25),
                            ),
                            margin: EdgeInsets.only(bottom: 180.h),
                            child: MyButton(
                              minWidth: 520.w,
                              minHeight: 80.h,
                              backgroundColor: Colors.transparent,
                              textColor: Colors.white,
                              fontSize: 36.sp,
                              text: "退出登录",
                              onPressed: () {
                                Get.find<MainState>().clearAuth();
                              },
                            ),
                          )
                        ],
                      ),
                    ),
                  ),
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
}
